﻿<%@ Page Language="C#" MasterPageFile="~/manager/logger.master" AutoEventWireup="true"
    CodeFile="customers.aspx.cs" Inherits="SmartParking.Web.Manager.Customers" Title="SmartParking >> Manager :: Parkings" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="ADEVSO" Namespace="ADEVSO.Web.UI.WebControls" TagPrefix="ADEVSO" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LoggerContentPlaceHolder" runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            //setup new customer dialog
            $('#pnlCustomerForm').dialog({
                autoOpen: false,
                closeOnEscape: true,
                draggable: false,
                modal: true,
                resizable: false,
                closeText: ' ',
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }
            });
        });

        function showDialog(id) {
            $('#' + id).dialog("open");
        }

        function closeDialog(id) {
            $('#' + id).dialog("close");
        }
              
    </script>
    <asp:UpdatePanel ID="upCustomer" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>
            <table width="100%" border="0" cellspacing="8" cellpadding="2">
                <tr>
                    <td>
                        <h1>
                            Manage Customers</h1>
                    </td>
                </tr>
                <tr>
                    <td>
                        <ADEVSO:GridView ID="grdCustomer" runat="server" AutoGenerateColumns="False" EnableViewState="true"
                            CellPadding="3" EmptyDataText="No customers found." OnRowCommand="grdCustomer_RowCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="IdCustomer" Visible="false">
                                    <ItemTemplate>
                                        <asp:Label ID="lbIdCustomer" runat="server" Text='<%# Bind("CustomerID") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Name">
                                    <ItemTemplate>
                                        <asp:Label ID="lbName" runat="server" Text='<%# Bind("Name") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Email Address">
                                    <ItemTemplate>
                                        <asp:Label ID="lbEmail" runat="server" Text='<%# Bind("Email") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Phone">
                                    <ItemTemplate>
                                        <asp:Label ID="lbPhone" runat="server" Text='<%# Bind("Phone") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Address">
                                    <ItemTemplate>
                                        <asp:Label ID="lbAddress" runat="server" Text='<%# Bind("Address") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnEdit" runat="server" Text="Edit" CommandName="EditCustomer"
                                            CausesValidation="false" CommandArgument='<%# Bind("CustomerID") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnDelete" runat="server" Text="Delete" CommandName="DeleteCustomer"
                                            CausesValidation="false" CommandArgument='<%# Bind("CustomerID") %>'></asp:LinkButton>
                                        <cc1:ConfirmButtonExtender ID="ceDelete" runat="server" ConfirmText="Are you sure that want to delete this customer?"
                                            TargetControlID="lbtnDelete">
                                        </cc1:ConfirmButtonExtender>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </ADEVSO:GridView>
                        <br />
                        <asp:LinkButton ID="lnkAddCustomer" runat="server" CausesValidation="false" OnClientClick="showDialog('pnlCustomerForm');">Add Customer</asp:LinkButton>
                    </td>
                </tr>
            </table>
            <br />
            <br />
        </ContentTemplate>
    </asp:UpdatePanel>
    <div id="pnlCustomerForm" class="modalPopup">
        <asp:UpdatePanel ID="upCustomerForm" UpdateMode="Conditional" ChildrenAsTriggers="true"
            runat="server">
            <ContentTemplate>
                <h2>
                    <asp:Label ID="lblCustomerTitle" runat="server" Text="Add Customer"></asp:Label>
                    <asp:HiddenField ID="hfIdCustomer" runat="server" />
                </h2>
                <table>
                    <tr>
                        <td>
                            Name:
                        </td>
                        <td>
                            <asp:TextBox ID="txtName" runat="server" Width="250px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvName" runat="server" ErrorMessage="*" ForeColor="Red"
                                Font-Bold="true" ControlToValidate="txtName"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Email Address:
                        </td>
                        <td>
                            <asp:TextBox ID="txtEmail" runat="server" Width="250px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ErrorMessage="*" ForeColor="Red"
                                Font-Bold="true" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revEmail" runat="server" ErrorMessage="*" ForeColor="Red"
                                Font-Bold="true" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Phone:
                        </td>
                        <td>
                            <asp:TextBox ID="txtPhone" runat="server" Width="250px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvPhone" runat="server" ErrorMessage="*" ForeColor="Red"
                                Font-Bold="true" ControlToValidate="txtPhone"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Address:
                        </td>
                        <td>
                            <asp:TextBox ID="txtAddress" runat="server" Width="250px" Rows="5" TextMode="MultiLine"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvAddress" runat="server" ErrorMessage="*" ForeColor="Red"
                                Font-Bold="true" ControlToValidate="txtAddress"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnSubmitCustomer" runat="server" Text="Save" OnClick="btnSubmitCustomer_Click" />
                            &nbsp;
                            <asp:Button ID="btnCancelCustomer" runat="server" Text="Cancel" CausesValidation="false"
                                OnClick="btnCancelCustomer_Click" />
                            &nbsp;
                            <asp:Button ID="btnDeleteCustomer" runat="server" Text="Delete" Visible="false" CausesValidation="false"
                                OnClick="btnDeleteCustomer_Click" />
                            <cc1:ConfirmButtonExtender ID="cbeDelete" runat="server" ConfirmText="Are you sure that want to delete this customer?"
                                TargetControlID="btnDeleteCustomer">
                            </cc1:ConfirmButtonExtender>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="uprCustomer" runat="server" AssociatedUpdatePanelID="upCustomerForm">
            <ProgressTemplate>
                <tr>
                    <td colspan="2" align="center">
                        <asp:Image ID="imgProgressCustomer" runat="server" ImageUrl="~/media/img/progress.gif" />
                        <asp:Label ID="lblWaitCustomer" runat="server" Text="Please wait..." />
                    </td>
                </tr>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
</asp:Content>
